/*
 * @lc app=leetcode.cn id=680 lang=cpp
 *
 * [680] 验证回文串 II
 */

// @lc code=start
#include <bits/stdc++.h>
using namespace std;
class Solution {
    bool valid(const string& s, int& l, int& r)
    {
        while(l < r && s[l] == s[r])
        {
            l++, r--;
        }
        return l >= r;
    }
public:
    bool validPalindrome(string s) {
        int l = 0, r = s.size() - 1;
        if(valid(s, l, r))
        {
            return true;
        }
        int ll = l + 1;
        int rr = r - 1;
        return valid(s, ll, r) || valid(s, l, rr);
    }
};
// @lc code=end

